INCLUDE(FindPackageHandleStandardArgs)
INCLUDE(HandleLibraryTypes)

SET(PTAM_IncludeSearchPaths
  /usr/include
  /opt/local/include
  
)

SET(PTAM_LibrarySearchPaths
  /usr/lib/
  /opt/local/lib/
)

FIND_PATH(TOON_INCLUDE_DIR TooN/TooN.h
  PATHS ${PTAM_IncludeSearchPaths}
)


FIND_PATH(GVARS3_INCLUDE_DIR gvars3/gvars3.h
  PATHS ${PTAM_IncludeSearchPaths}
)

FIND_LIBRARY(GVARS3_LIBRARY_OPTIMIZED
  NAMES GVars3
  PATHS ${PTAM_LibrarySearchPaths}
)


FIND_PATH(CVD_INCLUDE_DIR cvd/se3.h
  PATHS ${PTAM_IncludeSearchPaths}
)

FIND_LIBRARY(CVD_LIBRARY_OPTIMIZED
  NAMES cvd
  PATHS ${PTAM_LibrarySearchPaths}
)

# Handle the REQUIRED argument and set the <UPPERCASED_NAME>_FOUND variable
# The package is found if all variables listed are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PTAM "Could NOT find TooN"
  TOON_INCLUDE_DIR
)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(PTAM "Could NOT find GVars3 (PTAM)"
  GVARS3_LIBRARY_OPTIMIZED
  GVARS3_INCLUDE_DIR
)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(PTAM "Could NOT find cvd (PTAM)"
  CVD_LIBRARY_OPTIMIZED
  CVD_INCLUDE_DIR
)


# Collect optimized and debug libraries
HANDLE_LIBRARY_TYPES(GVARS3)
HANDLE_LIBRARY_TYPES(CVD)

MARK_AS_ADVANCED(
  TOON_INCLUDE_DIR

  GVARS3_INCLUDE_DIR
  GVARS3_LIBRARY_OPTIMIZED

  CVD_INCLUDE_DIR
  CVD_LIBRARY_OPTIMIZED
)
